echo off
echo "openocd update"
set cfgpwd=%cd:\=/%
echo %cfgpwd%
@REM set hexpwd=%cd:\=/%
@REM echo %hexpwd%
@REM for /f "delims=" %%i in ("%cd%") do set name=%%~ni
@REM echo %name%

set hexpath=""
for /r "%cd:\=/%/build" %%a in (*.hex) do (
    set hexpath=%%~dpa%%~nxa
)
echo %hexpath%
openocd -f %cfgpwd%/UserScript/openocd.cfg -c init -c halt -c "program %hexpath:\=/% verify reset exit" 